package com.qunar.train.mock.apache;

import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.Credentials;
import org.apache.http.client.CookieStore;
import org.apache.http.client.fluent.Executor;
import org.apache.http.client.fluent.Request;
import org.apache.http.client.fluent.Response;
import org.apache.http.conn.scheme.Scheme;

import mockit.Mock;
import mockit.MockUp;

public class MockExecutor {

    public static String VERSION = "1.0.0";


    public static ThreadLocal<MockExecutor> threadLocal = new ThreadLocal<>();

    public static MockExecutor getInstance() {
        if (threadLocal.get() == null) {
            threadLocal.set(new MockExecutor());
        }
        return threadLocal.get();
    }

    private org.apache.http.client.fluent.Executor authPreemptiveProxyReturnValue = null;
    private org.apache.http.client.fluent.Executor authPreemptiveReturnValue = null;
    private org.apache.http.client.fluent.Executor authReturnValuePAuthscopeCredentials = null;
    private org.apache.http.client.fluent.Executor authReturnValuePCredentials = null;
    private org.apache.http.client.fluent.Executor authReturnValuePHttphostCredentials = null;
    private org.apache.http.client.fluent.Executor authReturnValuePHttphostStringString = null;
    private org.apache.http.client.fluent.Executor authReturnValuePHttphostStringStringStringString = null;
    private org.apache.http.client.fluent.Executor authReturnValuePStringString = null;
    private org.apache.http.client.fluent.Executor authReturnValuePStringStringStringString = null;
    private org.apache.http.client.fluent.Executor clearAuthReturnValue = null;
    private org.apache.http.client.fluent.Executor clearCookiesReturnValue = null;
    private org.apache.http.client.fluent.Executor cookieStoreReturnValue = null;
    private boolean equalsReturnValue = false;
    private Response executeReturnValue = null;
    private int hashCodeReturnValue = 0;
    private org.apache.http.client.fluent.Executor newInstanceReturnValuePHttpclient = null;
    private org.apache.http.client.fluent.Executor newInstanceReturnValuePVoid = null;
    private String toStringReturnValue = null;

    public static void mockExecutor() {
        new MockExecutor.ExecutorMockUp();
    }

    public static class ExecutorMockUp extends MockUp<Executor> {
        @Mock
        public Executor authPreemptiveProxy(HttpHost arg0) {
            return getInstance().authPreemptiveProxyReturnValue;
        }

        @Mock
        public Executor authPreemptive(HttpHost arg0) {
            return getInstance().authPreemptiveReturnValue;
        }

        @Mock
        public Executor auth(AuthScope arg0, Credentials arg1) {
            return getInstance().authReturnValuePAuthscopeCredentials;
        }

        @Mock
        public Executor auth(Credentials arg0) {
            return getInstance().authReturnValuePCredentials;
        }

        @Mock
        public Executor auth(HttpHost arg0, Credentials arg1) {
            return getInstance().authReturnValuePHttphostCredentials;
        }

        @Mock
        public Executor auth(HttpHost arg0, String arg1, String arg2) {
            return getInstance().authReturnValuePHttphostStringString;
        }

        @Mock
        public Executor auth(HttpHost arg0, String arg1, String arg2, String arg3, String arg4) {
            return getInstance().authReturnValuePHttphostStringStringStringString;
        }

        @Mock
        public Executor auth(String arg0, String arg1) {
            return getInstance().authReturnValuePStringString;
        }

        @Mock
        public Executor auth(String arg0, String arg1, String arg2, String arg3) {
            return getInstance().authReturnValuePStringStringStringString;
        }

        @Mock
        public Executor clearAuth() {
            return getInstance().clearAuthReturnValue;
        }

        @Mock
        public Executor clearCookies() {
            return getInstance().clearCookiesReturnValue;
        }

        @Mock
        public Executor cookieStore(CookieStore arg0) {
            return getInstance().cookieStoreReturnValue;
        }

        @Mock
        public boolean equals(Object arg0) {
            return getInstance().equalsReturnValue;
        }

        @Mock
        public Response execute(Request arg0) {
            return getInstance().executeReturnValue;
        }

        @Mock
        public int hashCode() {
            return getInstance().hashCodeReturnValue;
        }

        @Mock
        public void registerScheme(Scheme arg0) {
        }

        @Mock
        public String toString() {
            return getInstance().toStringReturnValue;
        }

        @Mock
        public void unregisterScheme(String arg0) {
        }

        public static void clear() {
        }

    }

    public static void setAuthPreemptiveProxyReturnValue(org.apache.http.client.fluent.Executor p) {
        getInstance().authPreemptiveProxyReturnValue = p;
    }

    public static void setAuthPreemptiveReturnValue(org.apache.http.client.fluent.Executor p) {
        getInstance().authPreemptiveReturnValue = p;
    }

    public static void setAuthReturnValuePAuthscopeCredentials(org.apache.http.client.fluent.Executor p) {
        getInstance().authReturnValuePAuthscopeCredentials = p;
    }

    public static void setAuthReturnValuePCredentials(org.apache.http.client.fluent.Executor p) {
        getInstance().authReturnValuePCredentials = p;
    }

    public static void setAuthReturnValuePHttphostCredentials(org.apache.http.client.fluent.Executor p) {
        getInstance().authReturnValuePHttphostCredentials = p;
    }

    public static void setAuthReturnValuePHttphostStringString(org.apache.http.client.fluent.Executor p) {
        getInstance().authReturnValuePHttphostStringString = p;
    }

    public static void setAuthReturnValuePHttphostStringStringStringString(org.apache.http.client.fluent.Executor p) {
        getInstance().authReturnValuePHttphostStringStringStringString = p;
    }

    public static void setAuthReturnValuePStringString(org.apache.http.client.fluent.Executor p) {
        getInstance().authReturnValuePStringString = p;
    }

    public static void setAuthReturnValuePStringStringStringString(org.apache.http.client.fluent.Executor p) {
        getInstance().authReturnValuePStringStringStringString = p;
    }

    public static void setClearAuthReturnValue(org.apache.http.client.fluent.Executor p) {
        getInstance().clearAuthReturnValue = p;
    }

    public static void setClearCookiesReturnValue(org.apache.http.client.fluent.Executor p) {
        getInstance().clearCookiesReturnValue = p;
    }

    public static void setCookieStoreReturnValue(org.apache.http.client.fluent.Executor p) {
        getInstance().cookieStoreReturnValue = p;
    }

    public static void setEqualsReturnValue(boolean p) {
        getInstance().equalsReturnValue = p;
    }

    public static void setExecuteReturnValue(Response p) {
        getInstance().executeReturnValue = p;
    }

    public static void setHashCodeReturnValue(int p) {
        getInstance().hashCodeReturnValue = p;
    }

    public static void setNewInstanceReturnValuePHttpclient(org.apache.http.client.fluent.Executor p) {
        getInstance().newInstanceReturnValuePHttpclient = p;
    }

    public static void setNewInstanceReturnValuePVoid(org.apache.http.client.fluent.Executor p) {
        getInstance().newInstanceReturnValuePVoid = p;
    }

    public static void setToStringReturnValue(String p) {
        getInstance().toStringReturnValue = p;
    }


    public static void clear() {
        getInstance().authPreemptiveProxyReturnValue = null;
        getInstance().authPreemptiveReturnValue = null;
        getInstance().authReturnValuePAuthscopeCredentials = null;
        getInstance().authReturnValuePCredentials = null;
        getInstance().authReturnValuePHttphostCredentials = null;
        getInstance().authReturnValuePHttphostStringString = null;
        getInstance().authReturnValuePHttphostStringStringStringString = null;
        getInstance().authReturnValuePStringString = null;
        getInstance().authReturnValuePStringStringStringString = null;
        getInstance().clearAuthReturnValue = null;
        getInstance().clearCookiesReturnValue = null;
        getInstance().cookieStoreReturnValue = null;
        getInstance().equalsReturnValue = false;
        getInstance().executeReturnValue = null;
        getInstance().hashCodeReturnValue = 0;
        getInstance().newInstanceReturnValuePHttpclient = null;
        getInstance().newInstanceReturnValuePVoid = null;
        getInstance().toStringReturnValue = null;
    }


}
